package com.xiaojiang.blog.controller.blog;

import com.xiaojiang.blog.entity.vo.BlogDetailVO;
import com.xiaojiang.blog.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Auther: JiangShiyu
 * @Date: 2023/3/10 22:31
 * @Description: 关于我页面控制器 拓展页
 */
@Controller
public class AboutAndExpandPageController extends BaseController {
    @Resource
    private BlogService blogService;
    @Resource
    private ConfigService configService;
    @GetMapping({"/{subUrl}"})
    public String detail(HttpServletRequest request, @PathVariable("subUrl") String subUrl) {
        BlogDetailVO blogDetailVO = blogService.getBlogDetailBySubUrl(subUrl);
        if (blogDetailVO != null) {
            request.setAttribute("blogDetailVO", blogDetailVO);
            request.setAttribute("pageName", subUrl);
            request.setAttribute("configurations", configService.getAllConfigs());
            return "blog/" + theme + "/detail";
        } else {
            return "error/error_400";
        }
    }
}
